package service;

import java.util.*;

import beans.*;
import db.*;

public class patientService {
	public boolean login(String account,String password)
	{
		patientDAO patientDao=new patientDAO();
		return patientDao.valid(account, password);
	}
	
	public List<patientBean> browse(){
		patientDAO dao =new patientDAO();
		return dao.getAllRecords();
	}
	
	public boolean addpatient(patientBean patient)
	{
		patientDAO patientDao=new patientDAO();
		return patientDao.insertRecord(patient);
	}
	
	public patientBean getRecord(String patientId)
	{
		patientDAO patientDao=new patientDAO();
		return patientDao.getRecord(patientId);
	}
	
	public int delpatient(patientBean patient)
	{
		patientDAO patientDao=new patientDAO();
		if(patientDao.deleteRecord(patient))
			return 1;
		else
			return 2;
	}
	
	public int updatepatient(patientBean beforeRecord,patientBean afterRecord)
	{
		patientDAO patientDao=new patientDAO();
		if(patientDao.updateRecord(beforeRecord,afterRecord))
			return 1;
		else
			return 2;
	}
}
